<?php

$template = file_get_contents("test.inc");

$temp = explode("%%%", $template);

$templateArray = Array();

$divsArray = Array();

$divsArray['DIV1'] = "chuj ci w dupe stary";
$divsArray['DIV2'] = "twoja stara";
$divsArray['DIV3'] = "jesteś u pani";


foreach($temp as $k => $v)
{
	if($k%2==1)
		$templateArray[$v] = $divsArray[$v]; 
	else
		$templateArray[] = $v;
}

foreach($templateArray as $e)
{
	echo $e;
}

?>